#include "transport_layer.h"
#include "client_session_layer.h"

/* make request package ready to send to server */
req_packageT
make_req_package(double op1, double op2, int opCode)
{
	req_packageT req;

	req.opcode = opCode;
	req.op1 = op1;
	req.op2 = op2;

	return req;
}

/* unmake answer package, leave answer ready to print */
double 
unmake_ans_package(ans_packageT pAns)
{
	return pAns.ans;
}

/* request an operation and wait for the answer */
double 
doOperation(double op1, double op2, int opCode)
{
	ans_packageT pAns;
	req_packageT pReq;

	pReq = make_req_package(op1, op2, opCode);
	sendData(&pReq, sizeof(req_packageT));
	recvData(&pAns);
	return unmake_ans_package(pAns);
}
